# Maintainer: Caleb Maclennan <caleb@alerque.com>

pkgbase=lua-lub
_rockname=${pkgbase#lua-}
pkgname=("$pkgbase" "lua51-$_rockname" "lua52-$_rockname" "lua53-$_rockname")
pkgver=1.1.0
_rockrel=1
pkgrel=5
pkgdesc='Lubyk base module'
arch=(any)
url="https://lubyk.github.io/lubyk/$_rockname.html"
license=(MIT)
_luadeps=(filesystem)
makedepends=(lua
             lua51
             lua52
             lua53
             luarocks)
_archive="$_rockname-REL-$pkgver"
source=("https://github.com/lubyk/$_rockname/archive/REL-$pkgver/$_archive.tar.gz")
sha256sums=('355f427f28155c4cf3a9673aa24c3754ea782c1c5f2081cbc4c28c00ed69a0b7')

_package() {
	cd "$_archive"
	depends=("${pkgname%-*}" "${_luadeps[@]/#/${pkgname%-*}-}")
	luarocks --lua-version="$1" --tree="$pkgdir/usr/" \
		make --deps-mode=none --no-manifest "$_rockname-$pkgver-$_rockrel.rockspec"
	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE
}

package_lua-lub() {
	_package 5.4
}

package_lua53-lub() {
	_package 5.3
}

package_lua52-lub() {
	_package 5.2
}

package_lua51-lub() {
	_package 5.1
}
